# All configuration for plugins and other utils is defined here.
# Read more about `setup.cfg`:
# https://docs.python.org/3/distutils/configfile.html


[flake8]
# flake8 configuration:
# https://flake8.pycqa.org/en/latest/user/configuration.html
format = wemake
show-source = true
statistics = false
doctests = true
enable-extensions = G

# darglint configuration:
# https://github.com/terrencepreilly/darglint
strictness = long
docstring-style = numpy

# Flake plugins:
max-line-length = 80
max-complexity = 6

# Excluding some directories:
exclude = .git,__pycache__,.venv,.eggs,*.egg

# Disable some pydocstyle checks:
ignore = D100, D104, D106, D401, X100, W504, RST303, RST304, DAR103, DAR203

# Docs: https://github.com/snoack/flake8-per-file-ignores
# You can completely or partially disable our custom checks,
# to do so you have to ignore `WPS` letters for all python files:
per-file-ignores =
  # Allow `__init__.py` with logic for configuration:
  server/settings/*.py: WPS226, WPS407, WPS412, WPS432
  # Allow to have magic numbers inside migrations and wrong module names:
  server/*/migrations/*.py: WPS102, WPS114, WPS432
  # Enable `assert` keyword and magic numbers for tests:
  tests/*.py: S101, WPS432


[isort]
# isort configuration:
# https://github.com/PyCQA/isort/wiki/isort-Settings
include_trailing_comma = true
use_parentheses = true
# See https://github.com/PyCQA/isort#multi-line-output-modes
multi_line_output = 3
line_length = 80


[tool:pytest]
# pytest configuration:
# https://docs.pytest.org/en/stable/customize.html

# pytest-django configuration:
# https://pytest-django.readthedocs.io/en/latest/
DJANGO_SETTINGS_MODULE = server.settings

# Timeout for tests, so they can not take longer
# than this amount of seconds.
# You should adjust this value to be as low as possible.
# Configuration:
# https://pypi.org/project/pytest-timeout/
timeout = 5

# Strict `@xfail` by default:
xfail_strict = true

# Directories that are not visited by pytest collector:
norecursedirs = *.egg .eggs dist build docs .tox .git __pycache__

# You will need to measure your tests speed with `-n auto` and without it,
# so you can see whether it gives you any performance gain, or just gives
# you an overhead. See `docs/template/development-process.rst`.
addopts =
  --strict-markers
  --strict-config
  --doctest-modules
  --fail-on-template-vars
  # Output:
  --tb=short
  # Parallelism:
  # -n auto
  # --boxed
  # Coverage:
  --cov=server
  --cov=tests
  --cov-branch
  --cov-report=term-missing:skip-covered
  --cov-report=html
  --cov-report=xml
  --cov-fail-under=100


[coverage:run]
# Coverage configuration:
# https://coverage.readthedocs.io/en/latest/config.html
plugins =
  # Docs: https://github.com/nedbat/django_coverage_plugin
  django_coverage_plugin
  # Docs: https://pypi.org/project/covdefaults
  covdefaults

omit =
  # Is not reported, because is imported during setup:
  server/settings/components/logging.py


[mypy]
# Mypy configuration:
# https://mypy.readthedocs.io/en/latest/config_file.html
enable_error_code =
  truthy-bool,
  redundant-expr,
  unused-awaitable,
  ignore-without-code,
  possibly-undefined

allow_redefinition = false
check_untyped_defs = true
disallow_untyped_decorators = true
disallow_any_explicit = true
disallow_any_generics = true
disallow_untyped_calls = true
disallow_incomplete_defs = true
explicit_package_bases = true
ignore_errors = false
ignore_missing_imports = true
implicit_reexport = false
local_partial_types = true
strict_optional = true
strict_equality = true
show_error_codes = true
no_implicit_optional = true
warn_unused_ignores = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unreachable = true
warn_no_return = true

plugins =
  mypy_django_plugin.main

[mypy-server.apps.*.migrations.*]
# Django migrations should not produce any errors:
ignore_errors = true

[mypy.plugins.django-stubs]
# Docs: https://github.com/typeddjango/django-stubs
django_settings_module = server.settings
strict_settings = false


[doc8]
# doc8 configuration:
# https://github.com/pycqa/doc8
ignore-path = docs/_build
max-line-length = 80
sphinx = true
